#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void menu ()
{

    printf("------------------\n") ;
    printf("----- 1.play -----\n") ;
    printf("----- 0.exit -----\n") ;
    printf("------------------\n") ;
        
    printf("please choice:>") ;

}

void game ()
{

    int guess ;

    int random = rand () % 100 + 1 ;

    while(1)
    {

        printf("please guess the number:") ;

        scanf("%d" , &guess) ;

        if (guess < random)
        {

            printf("smaller\n") ;

        }

        else if (guess > random)
        {

            printf("bigger\n") ;

        }

        else
        {

            printf("congratulations , you are right!\n") ;

            break ;
            
        }

    }
}

int main ()
{

    srand ((unsigned int) time (NULL)) ;

    int choice = 0 ;

    do
    {

        menu () ;

        scanf("%d" , &choice) ;

        switch (choice)
        {

            case 0:
                printf("exit game\n") ;
                break;
            
            case 1:
                game () ;
                break ;

            default:
                printf("error number\n") ;
                break ;

        }

    } while (choice) ; 

    return 0 ;
    
}